package com.briup.app02.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app02.bean.BaseLog;
import com.briup.app02.service.IBaseLogService;
import com.briup.app02.utils.Message;
import com.briup.app02.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/baselog")
@Api(description = "系统日志表相关接口")
@Validated
public class BaseLogController {
			
		@Autowired
		private IBaseLogService baselogService;
		
		@GetMapping("query")
		@ApiOperation("查询所有日志信息")
		public Message query(String realname){
			List<BaseLog> list = baselogService.query(realname);
			return MessageUtil.success(list);			
		}

		@PostMapping("saveOrUpdate")
		@ApiOperation(value="保存或更新")
		@ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "主键",paramType = "form"),
            @ApiImplicitParam(name="realname",value = "名字",paramType = "form",required = true),
            @ApiImplicitParam(name="method",value = "方式",paramType = "form"),
            @ApiImplicitParam(name="content",value = "日志内容",paramType = "form"),
            @ApiImplicitParam(name="logTime",value = "日志时间",paramType = "form"),
    })
		public Message saveOrUpdate(BaseLog baselog) {
			baselogService.saveOrUpdate(baselog);
			return MessageUtil.success("操作成功");
		}
		
		@DeleteMapping("deleteById")
		@ApiOperation("根据id删除日志信息")
		@ApiImplicitParams({
			@ApiImplicitParam(name="id",value = "日志id",dataType = "long",paramType = "query",required = true)
		})
		public Message deleteById(@NonNull Long id) {
			baselogService.deleteById(id);
			return MessageUtil.success("删除成功");
		}
}
